using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Shop_Manage_replay_shop_message : Member, IRequiresSessionState
{
	protected TextBox TxtMessage;
	protected Button ButAdd;
	protected Button Button1;
	protected HtmlInputHidden ComeUrl;
	private int ShopID;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.ShopID = base.user.ShopID;
		if (this.ShopID <= 0)
		{
			this.WriteErrMsg("友情提示", Language.GetMemberMsg("Common/NoShop", new string[0]), "../Member/Shop_OpenShop.aspx");
		}
		if (!base.IsPostBack)
		{
			if (base.Request["action"] != null && base.Request["action"] == "update" && base.Request["messageID"] != null)
			{
				this.InitUpdateReplayMessage();
			}
		}
	}
	protected void ButAdd_Click(object sender, EventArgs e)
	{
		string text = this.TxtMessage.Text;
		int m_ID = Convert.ToInt32(base.Request.QueryString["messageID"]);
		int userID = base.user.UserID;
		Shop_Message shop_Message = new Shop_Message(this.conn);
		if (base.Request["action"] != null && base.Request["action"] == "update")
		{
			if (shop_Message.UpdateMessageByMessageID(m_ID, text))
			{
				this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('修改成功');location.href='shop_leave_message.aspx'</script>");
			}
			else
			{
				this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('修改失败，请稍候再试')</script>");
			}
		}
		else
		{
			if (shop_Message.ReplayMessage(text, userID, m_ID, base.user.UserName))
			{
				this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('回复成功');location.href='shop_leave_message.aspx'</script>", false);
			}
			else
			{
				this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('回复失败')</script>", false);
			}
		}
	}
	protected void Button1_Click(object sender, EventArgs e)
	{
		base.Response.Redirect("shop_leave_message.aspx");
	}
	protected void InitUpdateReplayMessage()
	{
		Shop_Message shop_Message = new Shop_Message(this.conn);
		int num = int.Parse(base.Request["messageID"]);
		if (num > 0)
		{
			DataTable messageByMessageID = shop_Message.GetMessageByMessageID(num);
			if (messageByMessageID.Rows.Count > 0)
			{
				this.TxtMessage.Text = messageByMessageID.Rows[0]["M_Content"].ToString();
			}
		}
	}
}
